#pragma strict
public static var isCrouching:boolean=false;
public static var isSprinting:boolean=false;

var player: Player;
var currentWeapon: Weapon;
var currentInteractable: Interactable;


function Start () {
	player = gameObject.GetComponent("Player");
	print(player);
	
}

function Update () {

	if(Input.GetButton("Sprint") && Player.stamina >2)
		{
			isSprinting=true;
			Player.stamina *= .99;
			//print(Player.stamina);
		}
	else
		{
			isSprinting=false;
		}
	if(Input.GetButton("Crouch"))
		{
			isCrouching=true;
		}
	else{
		isCrouching=false;
	}
	
	if(Input.GetButton("Fire1")){
			currentWeapon = player.getWeapon(0);
			currentWeapon.fire();
	}
	
	if(Input.GetButtonDown("Reload"))
		{
			 StartCoroutine(currentWeapon.reload());
		}
	if(Input.GetButton("Fire2"))
		{
			currentWeapon.fire();
		}
	
	if(Input.GetButtonUp("SwitchWeapon")){
		print("switch weapon");
		player.switchWeapon();	
	}
	if(Input.GetButtonUp("Action")){
		if(currentInteractable != null){
			currentInteractable.activate();
		}
	}
	
}

function OnGUI(){
	GUI.Label(new Rect(Screen.width*.5, Screen.height*.5, 20, 20), "O");
}

public function setInteractable(object: Interactable){
		currentInteractable = object;
}
public function clearInteractable(){
	currentInteractable = null;
}
